package com.codejam2010.round1c;

import java.io.File;
import java.io.PrintStream;
import java.util.Scanner;

public class A {

	int T, N, count;
	int[] a, b;

	public static void main(String[] args) throws Exception {
		A prob = new A();
		prob.solve();
	}
	
	public void solve() throws Exception {
		Scanner scanner = new Scanner(new File("input.txt"));
		PrintStream ps = new PrintStream(new File("output.txt"));
		System.setOut(ps);
		T = scanner.nextInt();
		for (int i=1;i<=T;++i) {
			count = 0;
			N = scanner.nextInt();
			a = new int[N+1];
			b = new int[N+1];
			for (int j=1;j<=N;++j) {
				a[j] = scanner.nextInt();
				b[j] = scanner.nextInt();
			}
			for (int j=1;j<=N;++j) {
				for (int k=j+1;k<=N;++k) {
					if (intersect(j, k)) {
						count++;
					}
				}
			}
			System.out.println("Case #" + i + ": " + count);
		}		
		ps.close();
	}
	
	private boolean intersect(int j, int k) {
		if ((a[j] - a[k]) * (b[j] - b[k]) < 0) 
			return true;
		return false;
	}

}
